Skip to content

feat(client-generator): send the SDK usage event as the cli-otel CloudEvent - #3371

Merged
AlbinaBlazhko17 merged 8 commits into
mainfrom
feat/sdk-usage-strict-event
Nov 6, 2026
Merged

AlbinaBlazhko17 merged 8 commits into
mainfrom
feat/sdk-usage-strict-event

Conversation

@AlbinaBlazhko17

@AlbinaBlazhko17 AlbinaBlazhko17 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What/Why/How?

The usage telemetry event of generated clients had its own shape: data was an object with usage and sdk maps, so it did not follow the CloudEvent schema of the other Redocly CLI events in @redocly/cli-otel.
The generated TypeScript, Python, Go, and PHP clients now send the com.redocly.sdkUsage.aggregated CloudEvent from @redocly/cli-otel 0.4.0: data holds the operation with its counts, then the SDK.

  • A generated client still has no dependencies. The TypeScript module types its event with the message type of @redocly/cli-otel, and the prepare script inlines that type into the runtime source.
  • The span attributes of every language are what processCloudEventAttributes of @redocly/cli-otel gives for the event. The end-to-end test of each language compares them key by key, so a change of the event in a new @redocly/cli-otel fails the tests until the four runtimes follow.
  • A custom sink receives the new event, so a sink that read data.usage must read the first item of data. The changeset says so.

Reference

Testing

Locally, unit and E2E tests. The events of generated TypeScript, Python, Go, and PHP clients were also sent to a local OpenTelemetry collector.

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

@AlbinaBlazhko17 AlbinaBlazhko17 self-assigned this Nov 5, 2026
@changeset-bot

changeset-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 13ef351

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@redocly/client-generator Minor
@redocly/cli Minor
@redocly/openapi-core Minor
@redocly/platform-integration Minor
@redocly/recheck Minor
@redocly/respect-core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

📝 Recheck Summary

⚠️ Warnings found • Scanned 1 changed file(s)

  • 0 error(s)
  • 4 warning(s)
  • 1 info

📋 Findings by rule

🟡 technical-english/sentence-length: 0 errors, 2 warnings, 0 info
🔵 technical-english/passive-voice: 0 errors, 0 warnings, 1 info
🟡 semantic-line-breaks: 0 errors, 2 warnings, 0 info

Errors fail the full-tree check. Warnings and info are a worklist and do not block the PR.

📖 Readability of changed files

Automated Readability Index (ARI): a U.S. grade level. Lower is easier to read.

File Base This PR Change
docs/@v2/commands/generate-client.md 6.4 6.3 ±0

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 82.66% (🎯 80%) 22015 / 26630
🔵 Statements 82.22% (🎯 80%) 23900 / 29068
🔵 Functions 84.4% (🎯 80%) 4261 / 5048
🔵 Branches 75.58% (🎯 75%) 16307 / 21575
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/client-generator/src/generators/typescript/telemetry/telemetry.ts 94.59% 85.1% 100% 96.81% 80, 107-108, 110-111, 136, 184, 242, 243, 403
packages/client-generator/src/runtime-sources/go-telemetry.ts 100% 100% 100% 100%
packages/client-generator/src/runtime-sources/php-telemetry.ts 100% 100% 100% 100%
packages/client-generator/src/runtime-sources/python-telemetry.ts 0% 100% 100% 0% 3
packages/client-generator/src/runtime-sources/telemetry.ts 100% 100% 100% 100%
Generated in workflow #13283 for commit 13ef351 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Performance Benchmark (Lower is Faster)

CLI Version Bundle Lint Check Config
latest ▓░░░░░░░░░░ 1.00x ▓░░░░░░░░░░ 1.00x ▓░░░░░░░░░░ 1.01x ± 0.01
next ▓░░░░░░░░░░ 1.01x ± 0.01 ▓░░░░░░░░░░ 1.01x ± 0.01 ▓░░░░░░░░░░ 1.00x

@AlbinaBlazhko17
AlbinaBlazhko17 marked this pull request as ready for review November 5, 2026 14:49
@AlbinaBlazhko17
AlbinaBlazhko17 requested review from a team as code owners November 5, 2026 14:49

@vadyvas vadyvas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

};
};
// The package root reaches its types through paths without an extension, which `nodenext`
// cannot resolve, so the types come from their own file. The prepare script inlines them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks bad, but it seems not in this pr

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add inside the cli-otel export, but it will be the separate PR.

// UsageTelemetryEvent is one com.redocly.sdkUsage.aggregated CloudEvent: the counts
// of one operation in one window. Data holds the operation, then the SDK; their values
// are strings or int64. Time is the window start in RFC 3339 with milliseconds. The
// OpenTelemetry collector sets the env of the event. The json tags give a Sink that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is hard to read. Suggest: "The json tags make a Sink that marshals an event write the CloudEvent field names, as in the other languages."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, with your wording.

Comment thread .changeset/strict-sdk-usage-event.md Resolved
@AlbinaBlazhko17
AlbinaBlazhko17 merged commit 70260c2 into main Nov 6, 2026
58 of 59 checks passed
@AlbinaBlazhko17
AlbinaBlazhko17 deleted the feat/sdk-usage-strict-event branch November 6, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants